package com.MovieManageSystem.mapper;

import com.MovieManageSystem.domain.Comment;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommentMapper {

    @Insert("INSERT INTO comment (vid, content) VALUES (#{movie.vid}, #{content})")
    @Options(useGeneratedKeys = true, keyProperty = "cid")
    void insertComment(Comment comment);

    @Select("SELECT * FROM comment WHERE vid = #{vid}")
    List<Comment> findByMovieVid(Integer vid);

    @Select("SELECT cid,vid,content FROM comment")
    List<Comment> findAllComments();

    @Delete("DELETE FROM comment WHERE cid = #{cid}")
    void deleteCommentByCid(Integer cid);

    @Select("SELECT * FROM comment")
    List<Comment> getCommentList();
}
